package com.google.code.chaotic.dto;

import java.io.Serializable;
import java.util.Comparator;

//

public class ServiceWaypointDto implements Serializable {

	/**
	 * @uml.property name="sequenceNo"
	 * 
	 *               Sequence numbers must start from 1, not 0.
	 */
	private Integer sequenceNo;

	/** @uml.property name="position" */
	private LatLonDto position;

	/**
	 * @uml.property name="commutingService"
	 * @uml.associationEnd 
	 *                     inverse="waypoints:com.google.code.chaotic.dto.CommutingService"
	 */
	private CommutingServiceDto commutingService;

	private String commutingServiceId;

	private String commutingHabitId;

	//

	/** @uml.property name="sequenceNo" */
	public Integer getSequenceNo() {
		return sequenceNo;
	}

	/** @uml.property name="sequenceNo" */
	public void setSequenceNo(Integer sequenceNo) {
		this.sequenceNo = sequenceNo;
	}

	/** @uml.property name="position" */
	public LatLonDto getPosition() {
		return position;
	}

	/** @uml.property name="position" */
	public void setPosition(LatLonDto position) {
		this.position = position;
	}

	/** @uml.property name="commutingService" */
	public CommutingServiceDto getCommutingService() {
		return commutingService;
	}

	/** @uml.property name="commutingService" */
	public void setCommutingService(CommutingServiceDto service) {
		this.commutingService = service;
		commutingServiceId = //
		(service != null ? service.getId() : null);
	}

	public String getCommutingServiceId() {
		return commutingServiceId;
	}

	public void setCommutingHabitId(String commutingHabitId) {
		this.commutingHabitId = commutingHabitId;
	}

	public String getCommutingHabitId() {
		return commutingHabitId;
	}

	//

	public static Comparator<ServiceWaypointDto> SEQUENCE_COMPARATOR //
	= new Comparator<ServiceWaypointDto>() {
		@Override
		public int compare(ServiceWaypointDto o1, ServiceWaypointDto o2) {
			return o1.getSequenceNo().compareTo(o2.getSequenceNo());
		}
	};
}
